/**
* Copyright (C), 2018-2030, Hisilicon Tech. Co., Ltd.
* All rights reserved.
*
* @file      kfifo.h
* @brief     mcu xxx  header file
* @author    xxxxx develop team
* @date      2019.01.05
*/

#ifndef __KFIFO_H_
#define __KFIFO_H_

#include "pm/hi_type.h"
#include "stdio.h"
#include "string.h"

#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* __cplusplus */


#ifndef MIN
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#endif

struct kfifo
{
    HI_U8* buffer; /* the buffer holding the data */
    HI_U16 size;   /* the size of the allocated buffer */
    HI_U16 in;     /* data is added at offset (in % size) */
    HI_U16 out;    /* data is extracted from off. (out % size) */
};

unsigned int     __kfifo_len(struct kfifo* fifo);
void             __kfifo_init(struct kfifo* fifo, HI_U8* pBuf, HI_U16 bufSize);
unsigned int     __kfifo_put(struct kfifo* fifo, HI_U8* buffer, HI_U16 len);
unsigned int     __kfifo_get(struct kfifo* fifo, HI_U8* buffer, HI_U16 len);
void             __kfifo_put_singlebyte(struct kfifo* fifo, HI_U8 data);


#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */


#endif /*__KFIFO_H_*/
